import http from "./http";

let api = {};

let fileAddr =  process.env.VUE_APP_fileAddr;
// 图片上传
api.uploadfile = async (params,config)=>{
    let res = await http.post("/api/web/file/upload",params,config);
    res.url = fileAddr + res.name;
    return Promise.resolve(res);
}

// base64 上传
api.uploadImgData = async (params,config)=>{
    let res = await http.post("/api/web/file/imgdata",params,config);
    res.url = fileAddr + res.name;
    return Promise.resolve(res);
}


// 获取根据id获取用户的信息
api.getUserById = (params)=>{
    return http.get("/api/web/user/info",params);
}

//注册
api.register = (params) => {
    return http.post("/api/web/user/register",params);
}

//登陆
api.login = (params) => {
    return http.post("/api/web/user/login",params);
}

//登出
api.logout = (params) => {
    return http.post("/api/web/loginout",params);
}

//新建
api.addPerson  = (params) => {
    return http.post("/api/app/person/add",params);
}

//获取列表
api.personList  = (params) => {
    return http.get("/api/app/person/list",params);
} 
api.personWebList = (params) => {
    return http.get("/api/web/person/list",params);
} 

api.info = (params) =>{
    return http.get("/api/app/person/info",params);
}

//编辑
api.editPerson  = (params) => {
    return http.post("/api/app/person/update",params);
}

//删除
api.delPerson  = (params) => {
    return http.post("/api/app/person/remove",params);
}

// 批量更新 /api/app/${nm}/updateOrders
api.updateOrders =  (params) => {
    return http.post("/api/app/person/updateOrders",params);
}

export default api;
